<?php
/**
 * @version SVN: $Id: ordertranslation.php 1149 2010-04-02 01:09:00Z elkuku $
 * @package    EasyCreator
 * @subpackage	Views
 * @author		EasyJoomla {@link http://www.easy-joomla.org Easy-Joomla.org}
 * @author		Nikolai Plath (elkuku) {@link http://www.nik-it.de NiK-IT.de}
 * @author		Created on 11-Sep-2008
 * @license    GNU/GPL, see JROOT/LICENSE.php
 */

// no direct access
defined( '_JEXEC' ) or die( ';)' );

if( ! $this->sel_language )
{
	ecrHTML::displayMessage(JText::_('Please choose a language'));

	return;
}

$cutAfter = JRequest::getInt('cut_after', 30);
?>

<table>
	<tr valign="top">
		<td>
			<?php drawTable($this->default_language, JText::_('Default language'), $cutAfter, false); ?>
		</td>
		<td>
			<?php drawTable($this->translated_language, JText::_('Translated language'), $cutAfter, false); ?>
		</td>
		<td>
			<?php drawTable($this->corrected_language, JText::_('Corrected language'), $cutAfter, true); ?>
		</td>
	</tr>
</table>

<?php
function drawTable($langFile, $title, $cutAfter, $displayFormField)
{
	?>
	<table class="adminlist">
		<tr>
			<th colspan="2"><?php echo $title; ?></th>
		</tr>
		<tr>
			<th><?php echo JText::_('Key'); ?></th>
			<th><?php echo JText::_('Value'); ?></th>
		</tr>
		<?php
		$k = 0;
		foreach ( $langFile as $line)
		{
			 ?>
			<tr class="row<?php echo $k; ?>">
			<?php
			if( $line->key == '#')
			{
			?>
				<td nowrap="nowrap" colspan="2" style="background-color: orange;">
					<?php echo displayCuttedTT($line->value, $cutAfter * 2);
					if( $displayFormField )
					{
						?>
						<input type="hidden" name="langfile[]" value="<?php echo $line->value; ?>" />
						<?php
					} ?>
				</td>
				<?php
			}
			else
			{
				?>
				<td nowrap="nowrap">
					<?php echo displayCuttedTT($line->key, $cutAfter); ?>
				</td>
				<td nowrap="nowrap">
					<?php echo displayCuttedTT($line->value, $cutAfter);
					if( $displayFormField )
					{
						$val =( $line->value ) ? $line->key.'='.$line->value : '';
						?>
						<input type="hidden" name="langfile[]" value="<?php echo $val; ?>" />
						<?php
					} ?>
				</td>
			</tr>
			<?php
			}

			$k = 1 - $k;
		}//foreach
		?>
	</table>
	<?php
}//function

/**
 * displays a span class="hasEasyTip" which will be rendered as a moootools tooltip
 *
 * @param string $string the (html) string to display
 * @param int $cutAfter numer of letters to display
 * @return html span with string as title
 */
function displayCuttedTT($string, $cutAfter)
{
	$ret = ecrHTML::cleanHTML(substr($string, 0, $cutAfter));
	if( strlen($string) > strlen($ret) )
	{
		$ret .= '<span class="hasEasyTip" style="border-bottom: 1px dotted orange" title="'.$string.'">...</span>';
	}

	return $ret;
}//function